home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 476 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: news.iag.net!news
  2. From: jatmon@iag.net (John R Buchan)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Using ARGV on VAX - how?
  5. Date: 5 Jan 1996 17:24:16 GMT
  6. Organization: Internet Access Group, Orlando, Florida
  7. Message-ID: <4cjms0$i5s@news.iag.net>
  8. References: <1996Jan5.091249.1@vax.sbu.ac.uk>
  9. NNTP-Posting-Host: pm3-orl15.iag.net
  10. X-Newsreader: WinVN 0.99.7
  11.  
  12. In article <1996Jan5.091249.1@vax.sbu.ac.uk>, tonyh@vax.sbu.ac.uk says...
  13. >
  14. <snip>
  15. >main (int argc, char *argv[])
  16. >{
  17. >    if (argv != 2) {
  18.  
  19. argv is a pointer to a pointer to a char.  It is unlikely to equal 2.
  20. I suspect that you intended to write:
  21.  
  22.     if (argc != 2) {
  23.  
  24. >        printf("you forgot to enter your name");
  25. >        exit(1);
  26. >    }
  27. >    printf("Hello %s", argv[1]);
  28. >}
  29. >when i type exe myfile.c  tony it should produce 'Hello Tony'
  30. >but all i get is :
  31. >
  32. >        "you forgot to enter your name"
  33.  
  34. I assume you are including strio.h?  You should probably add a return
  35. statement to the end of main.
  36.  
  37. -- 
  38. John R Buchan           -:|:-     Looking for that elusive FAQ?  ftp to:
  39. jatmon@mail.iag.net     -:|:-     rtfm.mit.edu /pub/usenet-by-group/....
  40.  
  41.